<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!-- 增加学期计划的时候，直接在创建时间时，增加标签 -->
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
 <!-- 增加用户开始 -->
			<div id="dialog-message_class">
				<div class="row">
					<div class="col-xs-3"> 
						 	<ul id="treeDemo4" class="ztree"></ul> 
					</div> 
					<div class="col-xs-9">
						 <form id="lable_from">
							<!-- <legend>Form</legend> -->
							<input type="hidden" id="lablePid" value="">
							 <table>
							 	<tr>
							 		<td width="50%">
								 		<fieldset>
											<label>标签名称：</label>
											<input type="text" id="name" value="${param.name}" require='true' name="name" meth="notNull" maxlength="30"  title="标签不能为空" />
											<span class="help-block"></span> 
										</fieldset>
							 		</td>
							 		<td width="50%">
							 		<fieldset>
										<label>分值：</label>
										<input type="text" id="lableValue" value="5"  name="lableValue"  maxlength="1" disabled="disabled"/>
										<span class="help-block"></span> 
									</fieldset>
							 		
							 		</td>
							 	</tr>
							 	<tr>
							 	<td>
							 	
							 			所属教材：&nbsp;&nbsp;
			 							   <div style="float:right;width:155px;">
					   						<select class="width-155 form-control" id="jiaocai">
												  <c:forEach items="${applicationScope.jiaocai}" var="ctemp">
												 	<option value="${ctemp.value1}">${ctemp.value1}</option> 
												 </c:forEach>
											</select>
											</div>	
							 	 
							 		</td>
							 		<td>
							 			重要性：&nbsp;&nbsp;
			 							   <div style="float:right;width:155px;">
					   						<select class="width-155 form-control" id="lableImportance">
												 <option value="1">一级</option>
												<option value="2">二级</option>
												<option value="3">三级</option>
												<option value="4">四级</option>
												<option value="5">五级</option>
												<option value="6">六级</option>
												<option value="7">七级</option>
												<option value="8">八级</option>
												<option value="9">九级</option>
											</select>
											</div>	
							 		</td> 
							 	</tr> 
							 		<tr>
								 		<td>
								 			 <fieldset>
										<label>上级标签：</label>
										<input type="text" id="pName1"  value=""   name="pName1"/>
										<span class="help-block"></span> 
									</fieldset> 
								 		</td> 
								 		
								 		<td>
		 								 
								 		</td>
							 	</tr> 
							 </table>  
						</form>		 
					</div>
				</div>

			 
									 
			</div>
			<!-- 增加用户结束-->
<script>
(function(){
	var setting = {	
			view: {
				dblClickExpand: false,
				showLine: true,
				selectedMulti: false
			},callback: {
				onClick: zTreeOnClick
			},
			data: { 
			simpleData: {
				enable:true,
				idKey: "lableId",
				pIdKey: "lablePid", 
				rootPId: "0"
			}
		}};
		//点击事件
		function zTreeOnClick(event, treeId, treeNode) { 	
	 
			 $("#lablePid").val(treeNode.lableId);
			 $("#pName1").val(treeNode.name);
			 
		};
	   function loadTree(){
		   var url ="${pageContext.request.contextPath}/edu/sys_LableAction.do?method=getAllLable";
			 $.ajax({
				   type: "POST",
				   url: url,				
				   dataType:"json",
				   success: function(msg){  
					   $.fn.zTree.init($("#treeDemo4"), setting, msg[0].list);
				   }
			}); 
	 }
	//增加用户
	 function addLearnPlantLable(contrl){
		var a =$("#lable_from").hzValidate("init");  
		if(a==false){
			return;
		}else{
			var object = OAajaxSubmit("lable_from"); 
			 var url ="${pageContext.request.contextPath}/edu/sys_LableAction.do?method=addSysLable1";
			 $.ajax({
				   type: "POST",
				   url: url,
				   data:object,
				   dataType:"json",
				   success: function(msg){   
					   if(msg.table_id){
						   alert("增加标签成功"); 
						   var vt='<button class="btn btn-xs btn-inverse" style="margin-top:4px;" name="lablebuton" table_id="'+msg.table_id+'">'+msg.name+'<i class="icon-remove"></i></button>';
						   $("#learnPlant_addLable_show").append(vt); 
						   $(contrl).dialog('destroy'); 
							$("#learnPlantAdd_ClassWindow").html("");
							$("button[name=lablebuton]").click(function(){
								$(this).remove();
							});
					   }else{
						 if(msg.message){
							 alert(msg.message);
						 }else{
							  alert("已经有此类标签");
						 }
					   }
				   }
			}); 
		}
	 };
	 $(function(){
 	  
		 if("${sessionScope.sysUser.userType}"=="5"){
			 loadTree();
		 }else{
			 $("#treeDemo4").parent().next().removeClass("col-xs-9").addClass("col-xs-12");
			 $("#treeDemo4").parent().remove();
		 }
		 if("${param.jiaocai}"!=""){
			 for(var i=0;i<$("#jiaocai").find("option").length;i++){
				 if($("#jiaocai").find("option")[i].value=="${param.jiaocai}"){
					 $("#jiaocai").find("option")[i].selected=true;
				 }
			 }
		 }
		 if("${param.lableImportance}"!=""){
			 for(var i=0;i<$("#lableImportance").find("option").length;i++){
				 if($("#lableImportance").find("option")[i].value=="${param.lableImportance}"){
					 $("#lableImportance").find("option")[i].selected=true;
				 }
			 }
		 }
	 });
	 window.learnPlantAdd_Lable_create={};
	 window.learnPlantAdd_Lable_create.addLearnPlantLable=addLearnPlantLable;
	
})()

</script>
